<?php

if(!$_SESSION) session_start();
// Connect to the database
////////////////////////////////////////////////////////

require_once("../scripts/config.php");

// Load Functions
////////////////////////////////////////////////////////

require_once("../scripts/functions.php");

// Insert Task
////////////////////////////////////////////////////////

if(isset($_POST) && ($_POST['set_post']==1)){

	$set_active = "0";

	if($_POST['set_active']=="yes") $set_active = 1;

	$sql = sprintf("INSERT INTO tblprojects (project_label,set_active,UserID) VALUES (%s, %s, %s)",
					GetSQLValueString($_POST['project_label'], "text"),
					GetSQLValueString($set_active, "int"),
					GetSQLValueString($_SESSION['UserID'], "int"));

	sqlMod($sql, $db);

        echo $sql;

	exit("Project Created Successfully!");

}

?>
<form id="formNP" name="formNP" method="POST" action="/forms/project_new.php">
  <p>
    <label>
      <input type="text" name="project_label" id="project_label" />
    </label>
    Project Name
    <input name="set_post" type="hidden" id="set_post" value="1" />
  </p>
  <p>
    <label>
      <input type="checkbox" name="set_active" id="set_active" value="yes" />
      This project is active and ready for tasks</label>
  </p>
</form>